<template>
	<view class="home">
		<view class="top">
		 <view class="nav">
			<navigator url="">
			   <image src="../../static/icon/house.png" mode=""></image>
			   <text>我的房屋</text>
			</navigator>
			<navigator url="">
			   <image src="../../static/icon/在线报修.png" mode=""></image>
			   <text>我的房屋</text>
			</navigator>
			<navigator url="">
			   <image src="../../static/icon/访客邀请.png" mode=""></image>
			   <text>我的房屋</text>
			</navigator>
		 </view>
		 <image class="banner" src="../../static/icon/banner.png" mode=""></image>
		 </view>
		<view class="msg">
			<view class="title">
				<image src="../../static/icon/aaa.png" />
				<text>社区</text>
				<text>公告</text>
			</view>
			<!-- uni-app中组件不需要注册 -->
			<view class="list" >
				<!-- 这里跳转不需要 -->
				<community-item  :url="'/pages/community-detail/community-detail?id=' + item.id"  :title="item.title" :info="item.content" 
				:pub_date="item.createdAt" v-for="item in list" :key="item.id">
				</community-item>
			</view>
		</view>
	</view>
</template>

<script>
	import {getCommunityList} from '@/api/home.js'
	export default {
		data() {
			return {
				list:[{
					title:'药品喷洒通知',
					info:'社区定于8月3日中午喷洒灭蚊药，提醒大家看管好小孩及宠物，不要到草坪中玩耍，以免造成不必要的危害。',
					pub_date:'2022-08-03 16:00',
					id:1
				},
				{
					title:'药品喷洒通知',
					info:'社区定于8月3日中午喷洒灭蚊药，提醒大家看管好小孩及宠物，不要到草坪中玩耍，以免造成不必要的危害。',
					pub_date:'2022-08-03 16:00',
					id:2
				}
				]
			}
		},
		methods:{
			async loadCommunityList(){
				const res = await getCommunityList()
				// console.log(res)
				this.list = res.data
			}
		},
		onLoad(){
			this.loadCommunityList()
		}
	}
</script>

<style lang="scss" scoped>
	.home{
		.top{
			height: 521rpx;
			width: 750rpx;
			background-color: #D2DDE8;
			overflow: hidden;
		    
			.nav{
				width: 670rpx;	
				height: 164rpx;
				border-radius: 16rpx;
				background-color: #fff;
				margin: 25rpx auto;
				display: flex;
				
				
				navigator {
					flex:1;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					
					image {
						width: 60rpx;
						height: 60rpx;
						
					}
					
					text {
						font-size: 24rpx;
						color:#686868;
						line-height: 30rpx;
						margin-top: 14rpx;
					}
				}
			}
			.banner{
				width: 670rpx;
				height: 240rpx;
				display: block;
				margin: 0 auto;
				position: relative;
				z-index: 2;
			}
		}
		.msg {
			height: 300rpx;
			border-radius: 20rpx;
			margin-top: -62rpx;
			background-color: #FBFBFF;
			margin-top: 30rpx;
			
			.title {
				padding: 0 40rpx;
				
				image {
					width: 48rpx;
					height: 40rpx;
					margin-right: 12rpx;
				}
				text {
					font-size: 36rpx;
					&:nth-child(2){
						color:#333333;
					}
					&:nth-child(3){
						color:#EBBB83;
					}
				}
			}
		}
		
	}
</style>